package view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

public class Label_draw {
	private Label label;
	private Image image;//对应的数字图片
	private Cursor cs_arrow;
	private Cursor cs_hand;
	public Label_draw(int Lx,int Ly,Shell shell,Cursor cs_arrow,Cursor cs_hand,Image image){
		this.cs_arrow = cs_arrow;
		this.cs_hand = cs_hand;
		this.image = image;
		label = new Label(shell,SWT.NONE);
		label.setAlignment(SWT.CENTER);
		label.setImage(SWTResourceManager.getImage(GMS.class, "/img/白色_38.png"));
		label.setBounds(Lx, Ly, 40, 40);
	}
	//判断是否获得焦点
	public boolean isFocus(){
		if(label.getBackground().equals(SWTResourceManager.getColor(SWT.COLOR_RED))){
			return true;
		}
		else{
			return false;
		}
	}
	//获得焦点
	public void setFocus(){
		label.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));
	}
	//失去焦点
	public void lostFocus(){
		label.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	}
	//面板为空
	public void setNone(){
		label.setImage(SWTResourceManager.getImage(GMS.class, "/img/白色_38.png"));
		label.setCursor(cs_arrow);
	}
	//面板是否为空
	public boolean isNone(){
		if(label.getImage().equals(SWTResourceManager.getImage(GMS.class, "/img/白色_38.png"))){
			return true;
		}
		else{
			return false;
		}
	}
	//显示面板
	public void setNum(){
		label.setImage(image);
		label.setCursor(cs_hand);
	}
	//获得面板
	public Label getLabel(){
		return label;
	}
	//组建消除
	public void ldDispose(){
		label.dispose();
		image.dispose();
		cs_arrow.dispose();
		cs_hand.dispose();
	}
	
}
